//
//  ICBaseSearchViewController.m
//  ICome
//
//  Created by chenqs on 2017/7/29.
//  Copyright © 2017年 iCom. All rights reserved.
//

#import "ICBaseSearchViewController.h"
#import "ICHeaderFile.h"

@interface ICBaseSearchViewController ()

@end

@implementation ICBaseSearchViewController

- (instancetype)initWithSearchResultsController:(UIViewController *)searchResultsController
{
    self = [super initWithSearchResultsController:searchResultsController];
    if (self) {
        
        [self setupSelf];
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated  {
    [super viewWillAppear:animated];
    [self setStatusBarBackgroundColor:[UIColor clearColor]];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self setStatusBarBackgroundColor:NE_BACKGROUND_COLOR];
}

- (void)setStatusBarBackgroundColor:(UIColor *)color {
    
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = color;
    }
}

- (void)setupSelf
{
    [self.searchBar sizeToFit];
    [self.searchBar setBarTintColor:BACKGROUNDCOLOR];
    [self.searchBar setTintColor:ICSEARCHCANCELCOLOR];
    [self.searchBar.layer setBorderWidth:0.5];
    [self.searchBar.layer setBorderColor:BACKGROUNDCOLOR.CGColor];
    self.dimsBackgroundDuringPresentation = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    self.hidesNavigationBarDuringPresentation = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)setPlaceholder:(NSString *)placeholder
{
    _placeholder = placeholder;
    [self.searchBar setPlaceholder:placeholder];
}
@end
